package com.competitions.videoedithelper.controller;

import com.competitions.videoedithelper.entity.ResponseModel;
import com.competitions.videoedithelper.service.impl.NewVideoServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;

/**
 * @author 盛旭雯
 */
@CrossOrigin
@RestController
@RequestMapping(value = "/newVideo")
public class NewVideoController {
    private NewVideoServiceImpl newVideoServiceImpl;

    @Autowired
    public NewVideoController(NewVideoServiceImpl newVideoServiceImpl) {
        this.newVideoServiceImpl = newVideoServiceImpl;
    }

    @RequestMapping(value = "/history",method = RequestMethod.GET)
    public void selectVideoList(HttpServletResponse resp, @RequestParam(value = "initVideoId")int initVideoId,
                                @RequestParam(value = "pageNum", required = false ,defaultValue = "1") int pageNum,
                                @RequestParam(value = "pageSize", required = false ,defaultValue = "10") int pageSize) {
        newVideoServiceImpl.selectVideos(resp, initVideoId, pageNum, pageSize);
    }

    @RequestMapping(value = "/videoInfo",method = RequestMethod.GET)
    public ResponseModel selectVideo(@RequestParam("videoId") int videoId) {
        return newVideoServiceImpl.selectVideo(videoId);
    }

    @RequestMapping(value = "/deleteVideo",method = RequestMethod.GET)
    public ResponseModel deleteVideo(@RequestParam("videoId") int videoId) {
        return newVideoServiceImpl.deleteVideo(videoId);
    }
}
